
import java.util.ArrayList;

/**
 * A class representing a route for a bus to take.
 *
 * A route is a list of locations for a bus to visit.
 * The route is identified by its name
 * @author higgina0
 */
public class Route
{
    private int routeID;
    //An array list representing all the locations on a given route
    private ArrayList<Location> locations;

    public Route(int routeID)
    {
        this.routeID = routeID;

        //Construct the array list representing all
        //locations on this route
        locations = new ArrayList<Location>();

        int locationIDs[] = BusStopInfo.getBusStops(this.routeID);
        for (int i = 0; i < locationIDs.length; i++)
        {
            this.locations.add(new Location(locationIDs[i]));
            if (this.locations.get(i).getStopName().equalsIgnoreCase("Back of Beyond"))
                System.out.println("Adding back of beyond!");
        }

    }

    public int getRouteID()
    {
        return this.routeID;
    }

    @Override
    public String toString() {
        return "Route{" + "routeID=" + routeID + '}';
    }
    
    

    /**
     * Get all the locations of a given route
     * @return an ArrayList containing every stop the route visits.
     */
    public ArrayList<Location> getLocations()
    {
        return this.locations;
    }

    public static ArrayList<Route> getRoutes()
    {
        int[] routeIDs = BusStopInfo.getRoutes();
        ArrayList<Route> routes = new ArrayList<Route>();

        for (int i = 0; i < routeIDs.length; i++)
        {
            routes.add(new Route(routeIDs[i]));
        }

        return routes;
    }
}
